﻿using Microsoft.Practices.Prism.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace WebServerConnectorDll
{
    [DataContract]
    public class CCoupon : NotificationObject, IFruitClass
    {
        private bool isChoose;
        private int uid;
        private String name;
        private float total;
        private float discount;
        private int status;
        private String statusName;
        private String endTime;

        public bool IsChoose
        {
            get
            {
                return isChoose;
            }
            set
            {
                isChoose = value;
                RaisePropertyChanged("IsChoose");
            }
        }

        [DataMember(Order = 0)]
        public int UID
        {
            get
            {
                return uid;
            }
            set
            {
                uid = value;
                RaisePropertyChanged("UID");
            }
        }

        [DataMember(Order = 1)]
        public String Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
                RaisePropertyChanged("Name");
            }
        }

        [DataMember(Order = 2)]
        public float Total
        {
            get
            {
                return total;
            }
            set
            {
                total = value;
                RaisePropertyChanged("Total");
            }
        }

        [DataMember(Order = 3)]
        public float Discount
        {
            get
            {
                return discount;
            }
            set
            {
                discount = value;
                RaisePropertyChanged("Discount");
            }
        }

        [DataMember(Order = 4)]
        public int Status
        {
            get
            {
                return status;
            }
            set
            {
                if(value == 0)
                {
                    StatusName = "停用";
                }
                else if(value == 1)
                {
                    StatusName = "启用";
                }

                status = value;
                RaisePropertyChanged("Status");
            }
        }

        [DataMember(Order = 4)]
        public String StatusName
        {
            get
            {
                return statusName;
            }
            set
            {
                statusName = value;
                RaisePropertyChanged("StatusName");
            }
        }

        [DataMember(Order = 5)]
        public String EndTime
        {
            get
            {
                return endTime;
            }
            set
            {
                endTime = value;
                RaisePropertyChanged("EndTime");
            }
        }

        public CCoupon(String pName, float pTotal, float pDiscount, int pStatus, String pEndTime)
        {
            Name = pName;
            Total = pTotal;
            Discount = pDiscount;
            Status = pStatus;
            EndTime = pEndTime;
        }

        public String ToInsertString()
        {
            return "\'" +Name + "\'-\'" + Total + "\'-\'" + Discount + "\'-\'" + Status + "\'-\'" + EndTime + "\'";
        }

        public String ToUpdateString()
        {
            return "Name=\'" + Name + "\',Total=\'" + Total + "\',Discount=\'" + Discount + "\',Status=\'" + Status + "\',EndTime=\'" + EndTime + "\'";
        }
    }
}
